package com.sam.im.heiqun.uis.adapters;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.sam.im.heiqun.R;
import com.sam.im.heiqun.entities.GroupEntivity;
import com.sam.im.heiqun.uis.adapters.holder.SectionalizationManagerHolder;

import java.util.List;

/**
 * Created by Joe on 2016/12/25.
 */

public class SectionalizationManagerAdpter extends RecyclerView.Adapter<SectionalizationManagerHolder> {

    private Context context;
    private List<GroupEntivity> mGroupEntivities;
    private SectionalizationManagerListClickListener mItemClickListener;

    public SectionalizationManagerAdpter(Context context, List<GroupEntivity> groupEntivities) {
        this.context = context;
        this.mGroupEntivities = groupEntivities;
    }
    public SectionalizationManagerAdpter(Context context) {
        this.context = context;
    }

    public void refresh( List<GroupEntivity> groupEntivities) {
        this.mGroupEntivities = groupEntivities;
        notifyDataSetChanged();
    }

    public interface SectionalizationManagerListClickListener {
        void onDeleteGroupClick(View view, int position);
    }

    public void setItemClickListener(SectionalizationManagerListClickListener mItemClickListener) {
        this.mItemClickListener = mItemClickListener;
    }


    @Override
    public SectionalizationManagerHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        context = parent.getContext();
        View view = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.item_sectionalization_manager, parent, false);
        return new SectionalizationManagerHolder(view, mItemClickListener);
    }

    @Override
    public void onBindViewHolder(SectionalizationManagerHolder holder, int position) {

     //   GlideUtils.loadImage(context, seckillProductItemEntity.getProductImg(), holder.image);

    }

    @Override
    public int getItemCount() {
        return mGroupEntivities != null ? mGroupEntivities.size() : 0;
    }
}